//小数点后留两位
function parseFloatExtend(val){
	if(val == ""){
		return 0;
	}
	return Math.round((parseFloat(val).toFixed(3))*100)/100;
}

//大写赋值
function getUpperStr(numberStr){
    var CN_ZERO = "零";
    var CN_ONE = "壹";
    var CN_TWO = "贰";
    var CN_THREE = "叁";
    var CN_FOUR = "肆";
    var CN_FIVE = "伍";
    var CN_SIX = "陆";
    var CN_SEVEN = "柒";
    var CN_EIGHT = "捌";
    var CN_NINE = "玖";
    var CN_TEN = "拾";
    var CN_HUNDRED = "佰";
    var CN_THOUSAND = "仟";
    var CN_TEN_THOUSAND = "万";
    var CN_HUNDRED_MILLION = "亿";
    var CN_SYMBOL = "人民币";
    var CN_DOLLAR = "元";
    var CN_TEN_CENT = "角";
    var CN_CENT = "分";
    var CN_INTEGER = "整";
    if (numberStr == null || numberStr =="")
    {
        return "";
    }

    if (numberStr == "0") return CN_ZERO;
    if (numberStr == "1") return CN_ONE;
    if (numberStr == "2") return CN_TWO;
    if (numberStr == "3") return CN_THREE;
    if (numberStr == "4") return CN_FOUR;
    if (numberStr == "5") return CN_FIVE;
    if (numberStr == "6") return CN_SIX;
    if (numberStr == "7") return CN_SEVEN;
    if (numberStr == "8") return CN_EIGHT;
    if (numberStr == "9") return CN_NINE;
    if (numberStr == "10") return CN_TEN;
    if (numberStr == "100") return CN_HUNDRED;
    if (numberStr == "1000") return CN_THOUSAND;
};
function jiesuanFeeUpper(){
    var jiesuan_fee = $("#jiesuan_fee").val() || '';

    var pointLocation = jiesuan_fee.indexOf(".");
    var intLength = jiesuan_fee.length;

    //整数长度
    intInterger = 0;
    if(pointLocation == -1){//没有小数点
        $("#jiesuan_daxie_fen").val(getUpperStr("0"));
        $("#jiesuan_daxie_jiao").val(getUpperStr("0"));

        intInterger = intLength;
    }else
    {
        if(jiesuan_fee.substring(pointLocation+2,pointLocation+3)){
			$("#jiesuan_daxie_fen").val(getUpperStr(jiesuan_fee.substring(pointLocation+2,pointLocation+3)));
		}else{
			$("#jiesuan_daxie_fen").val(getUpperStr("0"));
		}
		if(jiesuan_fee.substring(pointLocation+1,pointLocation+2)){
			$("#jiesuan_daxie_jiao").val(getUpperStr(jiesuan_fee.substring(pointLocation+1,pointLocation+2)));
		}else{
			$("#jiesuan_daxie_jiao").val(getUpperStr("0"));
		}

        intInterger = pointLocation;
    }


    $("#jiesuan_daxie_yuan").val(getUpperStr(jiesuan_fee.substring(intInterger-1,intInterger)));
    $("#jiesuan_daxie_shi").val(getUpperStr(jiesuan_fee.substring(intInterger-2,intInterger-1)));
    $("#jiesuan_daxie_bai").val(getUpperStr(jiesuan_fee.substring(intInterger-3,intInterger-2)));
    $("#jiesuan_daxie_qian").val(getUpperStr(jiesuan_fee.substring(intInterger-4,intInterger-3)));
    var wanStr = "";


    if (intInterger ==5)
    {
        wanStr = getUpperStr(jiesuan_fee.substring(intInterger-5,intInterger-4));
    }else if (intInterger ==6)
    {
        wanStr = getUpperStr(jiesuan_fee.substring(intInterger-6,intInterger-5))+getUpperStr("10")+getUpperStr(jiesuan_fee.substring(intInterger-5,intInterger-4));
    }else if (intInterger ==7)
    {
        wanStr = getUpperStr(jiesuan_fee.substring(intInterger-7,intInterger-6))+getUpperStr("100")+getUpperStr(jiesuan_fee.substring(intInterger-6,intInterger-5))+getUpperStr("10")+getUpperStr(jiesuan_fee.substring(intInterger-5,intInterger-4));
    }
    else if (intInterger ==8)
    {
        wanStr = getUpperStr(jiesuan_fee.substring(intInterger-8,intInterger-7))+getUpperStr("1000")+getUpperStr(jiesuan_fee.substring(intInterger-7,intInterger-6))+getUpperStr("100")+getUpperStr(jiesuan_fee.substring(intInterger-6,intInterger-5))+getUpperStr("10")+getUpperStr(jiesuan_fee.substring(intInterger-5,intInterger-4));
    }else if (intInterger >8)
    {
        wanStr = "不合理数据";
    }
    $("#jiesuan_daxie_wan").val(wanStr);

};

function inputAllByHand(){
	$("input[type='text']").attr("readonly",false);
	$("#zf_level1").attr("readonly",true);
	$("#zf_level1").val("正房一等");
	$("#zf_level2").attr("readonly",true);
	$("#zf_level2").val("正房二等");
	$("#xf_level1").attr("readonly",true);
	$("#xf_level1").val("小房一等");
}

$(function(){
	$('#jiesuan_fee').bind('blur',function(){
		jiesuanFeeUpper();
	});
});